---
layout: page
title: 分组
tagline: 按照所属组别展示
header: Post By Groups
permalink: /groups/
comments: false
---
{% include JB/setup %}

{% assign posts_by_group = site.posts | group_by:"group" | sort:"group" %}

{% assign x_label = '组别' %}
{% assign y_label = '数目' %}

{% assign list = nil %}
{% assign group_size = 0 %}
{% assign item_max_length = 8 %}

{% for group in posts_by_group %}
  {% if group.name == 'original' %}
    {% assign group_size = group.items.size %}
    {% continue %}
  {% endif %}

  {% assign group_name = site.data.groups[group.name] %}

  {% if group.name == empty %}
    {% assign group_name = site.data.groups['original'] %}
    {% assign group_size = group.items.size | plus: group_size %}
  {% else %}
    {% assign group_size = group.items.size %}
  {% endif %}

   {% assign item_size = group_size %}
   {% assign item_length = item_size | append:'' | size %}
   {% assign item_zeros = item_max_length | minus: item_length %}
   {% assign prefix_zeros = '' %}
   {% for i in (1..item_zeros) %}
     {% assign prefix_zeros = prefix_zeros | append:'0' %}
   {% endfor %}

   {% assign list0 = prefix_zeros | append:item_size | append:',' | append: group_name %}
   {% if list == nil %}
     {% assign list = list0 %}
   {% else %}
     {% assign list = list | append:';' | append: list0 %}
   {% endif %}


  <h3 id="{{ group_name | downcase | replace:' ','-' | replace:'/','-' }}-ref">{{ group_name}} <sup>({{ group_size }})</sup></h3>
  <ul>
    {% for post in group.items %}

    {% if post.draft and post.draft == true %}
      {% continue %}
    {% endif %}

    <li><a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endfor %}
  </ul>
{% endfor %}

{% assign list = list | split:';' | sort | reverse %}

<h3>{{ x_label}}统计 <sup>({{ site.posts.size }})</sup></h3>
{% include widgets/svg_statistic %}
